<?php

namespace Design\Behavioral\ChainOfResponsibilities;

use Psr\Http\Message\RequestInterface;

abstract class Handler
{

    private $successor = null;


    public function __construct(Handler $handler=null)
    {
        $this->successor = $handler;

    }//end __construct()


    final public function handle(RequestInterface $request)
    {
        $processed = $this->processing($request);

        if ($processed === null && $this->successor !== null) {
            $processed = $this->successor->processing($request);
        }

        return $processed;

    }//end handle()


    abstract protected function processing(RequestInterface $request);


}//end class
